<template>
    <view>
        <view class="footer-container" v-if="campanyInfo.memberId == userInfo.id">
            <view class="footer-btn" style="background: rgba(246, 249, 248, 1)">
                <!-- <view class="left-btn row" style=" justify-content: center" @click="consultation">
                    <image :src="require('../../static/zhuanjiaxuezhe.png')" style="width: 32rpx; height: 32rpx">
                    </image>
                    <text style="margin-left: 14rpx; font-weight: bold">咨询</text>
                </view> -->
                <!-- <view class="right-btn row" style="justify-content: center" @click="sharePlan">
                    <image :src="require('../../static/fenxiang.png')" style="width: 32rpx; height: 32rpx"></image>
                    <text style="margin-left: 14rpx; font-weight: bold">分享方案</text>
                </view> -->
                <button class="right-btn" open-type="share">分享方案</button>
            </view>
        </view>

        <uni-popup ref="consult" background-color="#fff">
            <view class="consultContent">
                <view class="popTitle">申请专家咨询</view>
                <view class="popContent paddingL20">{{ isTaxMatch ? popBefore : popContent }}</view>
                <view class="row popBottom" v-if="isTaxMatch">
                    <view style="background: #f6f9f8; border: 2rpx solid #dfe0e0; color: #c7c7c7" @click="stillApply">
                        仍然申请</view>
                    <view @click="goSupplement">去补充</view>
                </view>
                <view class="row popBottom" v-else>
                    <view @click="customerService">联系客服</view>
                    <view @click="IKnowClick">我知道了</view>
                </view>
            </view>
        </uni-popup>


    </view>
</template>

<script>
import { customerConsultaApi, getMatchInfoInfo } from '@/api/product'
import store from '@/store';
export default {

    props: {
        campanyInfo:{
            type: Object,
            default: () => {
                return {}
            }
        },
        isTaxMatch: {
            type: Boolean,
            default: false
        },
        queryOptions: {
            type: Object,
            default: () => { }
        }
    },
    data() {
        return {
            popContent: '申请已提交成功，顺潇会在两个工作日内为您安排一对一的助融专家联系您，请留意接听电话！',
            popBefore: '你还未进行税票匹配，申请专家咨询之前完成税票匹配会给出更全面、更专业的分析建议！',
            isMatch: false,
            userInfo: {}
        }
    },

    created() {
        this.getUserInfo()
    },
    methods: {
        getUserInfo() {
            store.dispatch('USERINFO').then((res) => {
                this.userInfo = res;
            });
        },
        goSupplement() {
            getMatchInfoInfo({
                id: this.queryOptions.id,
                type: this.queryOptions.type
            }).then((res) => {
                let params = {
                    tax: res.data.creditCode,
                    companyName: res.data.enterpriseName,
                    matchType: this.queryOptions.type,
                    age: res.data.ageScope,
                    phoneNumber: res.data?.phoneNumber,
                    role: res.data.personStand,
                    provinceId: res.data.areaId,
                    matchStep: this.queryOptions.matchStep + ''
                };
                let url = Object.keys(params).reduce((pre, cur) => {
                    return pre + (params[cur] ? `&${cur}=${params[cur]}` : '');
                }, '');
                uni.navigateTo({
                    url: `/pagesProduct/addCampanyData/index?${url.substring(1, url.length)}`
                });
                this.$refs.consult.close();
            });
        },
        customerService() {
            // #ifdef MP-WEIXIN
            wx.openCustomerServiceChat({
                extInfo: {
                    url: 'https://work.weixin.qq.com/kfid/kfc389dffe7ae981936'
                },
                corpId: 'ww1c4069be6ea4025e',
                showMessageCard: true,
                success(res) {
                    console.log(res);
                },
                fail(err) {
                    console.log(err);
                },
            })
            // #endif
        },
        IKnowClick() {
            this.$refs.consult.close();
        },
        consultation() {
            this.$refs.consult.open('center');
            if (['1', '2', '3'].includes(this.queryOptions.matchStep + '')) {
                this.stillApply();
            }
        },
        sharePlan() {

        },
        stillApply() {
            customerConsultaApi({
                id: this.queryOptions.id,
                type: this.queryOptions.type
            }).then((res) => {
                this.$emit('editIsTaxMatch', false)

                // uni.navigateTo({ url: `/pageHome/company/matchResult?enterpriseId=${this.queryOptions.enterpriseId}&id=${this.queryOptions.id}&type=${this.queryOptions.type}&matchStep=1` })
            });
        }
    },
}
</script>

<style scoped lang="scss">
.footer-container {
    background: rgba(246, 249, 248, 1);
    width: 100vw;
    position: fixed;
    bottom: 0rpx;
    left: 50%;
    right: 30rpx;
    transform: translateX(-50%);
    z-index: 10;
}

.footer-btn {
    display: flex;
    justify-content: space-between;
    align-content: center;
    // padding: 30rpx 0;
    margin: 0 30rpx;

    .left-btn {
        width: 330rpx;
        height: 88rpx;
        background: #ffe7d2;
        border-radius: 12rpx 12rpx 12rpx 12rpx;
        border: 1rpx solid #fa7700;
        color: #fa7700;
        font-size: 34rpx;
        text-align: center;
        line-height: 88rpx;
    }

    // .report-btn {
    //     width: 250rpx;
    //     height: 88rpx;
    //     background: #fa7700;
    //     border-radius: 12rpx 12rpx 12rpx 12rpx;
    //     border: 1rpx solid #fa7700;
    //     color: #FFFFFF;
    //     font-size: 34rpx;
    //     text-align: center;
    //     line-height: 88rpx;

    // }


    .report-btn-disable {
        background: #999 !important;
        border: none;

    }

    .right-btn {
        width: 660rpx;
        height: 88rpx;
        font-size: 34rpx;
        background: #2872fd;
        border-radius: 12rpx 12rpx 12rpx 12rpx;
        color: #fff;
        text-align: center;
        line-height: 88rpx;
    }
}

.consultContent {
    width: 620rpx;
    height: 400rpx;
    border-radius: 32rpx;
    position: relative;
    background-color: #fff;

    .popTitle {
        font-size: 36rpx;
        font-weight: 600;
        text-align: center;
        padding-top: 24rpx;
        padding-bottom: 20rpx;
        border-bottom: 1rpx solid #e6e6e6;
    }

    .popContent {
        margin-top: 40rpx;
        color: #999999;
        line-height: 48rpx;
    }

    .popBottom {
        margin-top: 30rpx;
        position: absolute;
        width: 60%;
        left: 50%;
        bottom: 80rpx;
        transform: translateX(-50%);

        view {
            width: 180rpx;
            //height: 40rpx;
            background: #2872fd;
            color: #ffffff;
            text-align: center;
            padding: 12rpx 24rpx;
            font-size: 32rpx;
            font-weight: bold;
            border-radius: 8rpx;
        }
    }
}
</style>